#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMessageBox>
#include <QPainter>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QString>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

    // 绘图事件
    void paintEvent(QPaintEvent*);
    void serial_Send(QString text);

private slots:
    void on_btnSwitch_clicked();

    void serialPortRead_Slot();

    void on_btnSend_clicked();

    void on_btnClearRec_clicked();

    void on_btnClearSend_clicked();

    void on_chkRec_stateChanged(int arg1);

    void on_chkSend_stateChanged(int arg1);

    void on_chkTimSend_stateChanged(int arg1);

    void on_btnSend_M0_clicked();

    void on_btnSend_M1_clicked();

    void on_btnSend_M2_clicked();

    void on_btnSend_M3_clicked();

    void on_btnSend_M4_clicked();

    void on_btnSend_M5_clicked();

    void on_btnSend_M6_clicked();

    void on_btnSend_M7_clicked();

    void on_btnSend_M8_clicked();

    void on_btnSend_M9_clicked();

private:
    Ui::MainWindow* ui;

    QSerialPort* mySerialPort;

    // 发送、接收字节计数
    long sendNum, recvNum;
    QLabel* lblSendNum;
    QLabel* lblRecvNum;
    void setNumOnLabel(QLabel* lbl, QString strS, long num);

    // 定时发送-定时器
    QTimer* timSend;
};
#endif // MAINWINDOW_H
